var app = getApp();
var Const = require('./../../utils/const.js');
const Zan = require('../../dist/index');

Page(Object.assign({}, Zan.TopTips, {

	data: {
		title: '',
		article: ''
	},

	onLoad: function (options) {
		var id = options.id, that = this;

		var title = '';
		if (id == '1') {
			title = '关于我们';
		} else if (id == '2') {
			title = '用户协议';
		} else if (id == '3') {
			title = '押金说明';
		} else if (id == '4') {
			title = '充值协议';
		}

		that.setData({
			title: title
		});

		wx.setNavigationBarTitle({
			title: title
		});

		//get article
		that._getArticleDetail(title);
	},

	onShow: function () {

	},

	_getArticleDetail: function (title) {
		let that = this;
		app.battery.common('article/detail', {
			title: that.data.title,
		}).then(function (data) {
			let content = data.content.replace(/&#8232;/g, "");
			that.setData({
				article: content
			})

		}).catch(function (e) {
			that.showZanTopTips(e.message, {type: 'error'});
		});
	}
}));